package net.xxcxcxcx.xc_enhancedmob.skills.basics.individual.common;

import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.nbt.NbtCompound;
import net.xxcxcxcx.xc_enhancedmob.config.skill.SkillConfig;
import net.xxcxcxcx.xc_enhancedmob.skills.BaseSkill;

public class ShadowSkill extends BaseSkill {

    public ShadowSkill(int level) {
        super(level);
    }

    public ShadowSkill(NbtCompound nbtCompound) {
        super(nbtCompound);
    }

    public ShadowSkill() {
    }

    @Override
    public SkillConfig getDefaultConfig() {
        SkillConfig skillConfig = super.getDefaultConfig();
        skillConfig.setMessage(getConfigMessage(skillConfig));
        return skillConfig;
    }

    @Override
    public String getConfigMessage(SkillConfig skillConfig) {
        if (skillConfig == null) return super.getConfigMessage(null);
        return String.format("暗影技能，亮度不足的地方进行隐身。");
    }

    @Override
    public boolean passiveApply(MobEntity mobEntity) {
        if (mobEntity.world.getTime() % 100 == 0
                && mobEntity.world.getBaseLightLevel(mobEntity.getBlockPos(), 15) < 3)
            mobEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.INVISIBILITY, 120, 0));
        return true;
    }
}
